package com.guxingke.typecho4j.widget.provider.option;

import com.guxingke.typecho4j.Typecho4jException;
import com.guxingke.typecho4j.widget.WidgetProvider;
import com.guxingke.typecho4j.widget.provider.OptionBaseWidget;
import com.jfinal.core.Controller;

/**
 * 默认编辑配置信息组件
 * 
 * @author guxingke
 *
 */
public class EditOptionWidget extends OptionBaseWidget implements
		WidgetProvider {

	private boolean defaultAllowComment;
	private boolean defaultAllowFeed;
	private boolean defaultAllowPing;

	@Override
	public boolean init() {
		initLogger();
		InitParam();
		return true;
	}

	private void InitParam() {
		defaultAllowComment = ("1"
				.equals(getValue("defaultAllowComment"))) ? true
				: false;
		defaultAllowFeed = ("1".equals(getValue("defaultAllowFeed"))) ? true
				: false;
		defaultAllowPing = ("1".equals(getValue("defaultAllowPing"))) ? true
				: false;
	}

	@Override
	public void excute(Controller controller) throws Typecho4jException {
		controller.setAttr("editOption", this);
	}

	@Override
	public void refresh() {
		InitParam();
	}

	public boolean isDefaultAllowComment() {
		return defaultAllowComment;
	}

	public boolean isDefaultAllowFeed() {
		return defaultAllowFeed;
	}

	public boolean isDefaultAllowPing() {
		return defaultAllowPing;
	}
}
